package edu.luc.concordia;

import java.util.ArrayList;

/**
 * Copyright 2008 Project Concordia
 * <p>
 * This file is part of RetailReturnSystem.
 * <p>
 * RetailReturnSystem is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 * <p>
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * <p>
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <a
 * href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>.
 * <hr>
 * Represents a Product object.
 * 
 * @author Chris Bun
 * @version 0.1 2008-10-07
 */

public class Product {
	private String myUID;
	private String myDescription;
	private ArrayList<PriceScheme> myPriceSchemes;
	private double myCalculatedPrice; // TODO
	private boolean isTaxable;
	private String myCategoryID;

	/**
	 * Class constructor
	 * 
	 * @param uid
	 *            a unique, 10-digit ID number.
	 * @param description
	 *            a short description of the product consisting of 6 to 40
	 *            characters.
	 */
	public Product(String uid, String description) {
		myUID = uid;
		myDescription = description;
		myPriceSchemes = new ArrayList<PriceScheme>();
		myCalculatedPrice = PriceScheme.CAN_NOT_BUY;
	}

	/**
	 * Copy constructor. Needed to avoid pointer issues.
	 * 
	 * @param oldProd
	 *            Old product to copy.
	 */
	public Product(Product oldProd) {
		myUID = oldProd.getUID();
		myDescription = oldProd.getDescription();
		myCalculatedPrice = oldProd.getCalculatedPrice();
		isTaxable = oldProd.isTaxable();
		myCategoryID = oldProd.getCategoryID();

		myPriceSchemes = new ArrayList<PriceScheme>();
		myPriceSchemes.addAll(oldProd.getPriceScheme());
	}

	/**
	 * Returns the product's unique, 10-digit ID number.
	 */
	public String getUID() {
		return myUID;
	}

	/**
	 * Returns the product's 6 to 40 character long description.
	 */
	public String getDescription() {
		return myDescription;
	}

	/**
	 * Adds a PriceScheme to the product's myPriceSchemes ArrayList.
	 * 
	 * @param price
	 *            the PriceScheme to be added to myPriceSchemes.
	 */
	public void addPriceScheme(PriceScheme price) {
		myPriceSchemes.add(price);
	}

	/**
	 * Returns the ArrayList myPriceSchemes.
	 */
	public ArrayList<PriceScheme> getPriceScheme() {
		return myPriceSchemes;
	}

	public void setIsTaxable(boolean tax) {
		isTaxable = tax;
	}

	public boolean isTaxable() {
		return isTaxable;
	}

	public synchronized double getCalculatedPrice() {
		return myCalculatedPrice;
	}

	public synchronized void setCalculatedPrice(double calculatedPrice) {
		myCalculatedPrice = calculatedPrice;
	}

	public synchronized String getCategoryID() {
		return myCategoryID;
	}

	public synchronized void setCategoryID(String categoryID) {
		myCategoryID = categoryID;
	}
}